<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
    <AppMenu
        :class="classNames"
        :defaultExpands="store.defaultExpands"
        :menus="store.menus"
        :selections="store.selections"
        :mode="props.mode"
        :openViewCodeName="store.openViewCodeName"
        :counterData="props.counterData"
        :context="store.context"
        :viewParams="store.viewParams"
        @menuClick="handleMenuClick"
    ></AppMenu>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@APPMENU}}-menu/\{{spinalCase ctrl.codeName}}-menu.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
import { AppMenu } from '@components/widgets/menu';
import { model } from './{{spinalCase ctrl.codeName}}-menu-model';
import { useNavParamsBind, getCtrlClassNames, useEventBind } from '@/hooks/use-ctrl';
import { AppMenuActionType, AppMenuController, IAppMenuAbility, IAppMenuController, IAppMenuControllerParams, IAppMenuStore, IContext, ILoadingHelper, IParam, IViewCtx } from '@/core';

{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="viewStyle: string;
    mode: string;
    isDefaultPage: boolean;
    isBlankMode: boolean;
    defPSAppView?: string;
    counterData:IParam;    
    "
    propsDefault="viewStyle: 'DEFAULT',
    mode: 'LEFT'"
}}


{{> @macro/common/emit.hbs name="ctrl" actionType="AppMenuActionType" ability="IAppMenuAbility"}}


const classNames = computed(() => {
  const names = getCtrlClassNames(model, props);
  if (props.mode) {
    Object.assign(names, {
      [`app-control-menu--${props.mode.toLowerCase()}`]: true,
    });
  } else {
    Object.assign(names, { [`app-control-menu--left`]: true });
  }
  return names;
});

const params:IAppMenuControllerParams<AppMenuActionType, IAppMenuAbility> = {
    name: props.name,
    model,
    evt,
    mode: props.mode,
    isDefaultPage: props.isDefaultPage,
    isBlankMode: props.isBlankMode,
    defPSAppView: props.defPSAppView,
    closeView: props.closeView,
    pLoadingHelper: props.pLoadingHelper,
    pViewCtx: props.pViewCtx,
    actions: { },
    handler: (data: IAppMenuStore) => { return reactive(data) }
};

{{> @macro/common/controller.hbs name="ctrl" IController="IAppMenuController" store="IAppMenuStore" ability="IAppMenuAbility" controller="AppMenuController"}}


const handleMenuClick = (name: string) => {
    controller.handleMenuClick(name);
}
</script>